/**
 * 
 * If you have edited the file, please update
 * all the last-modified fields manually. Thanks!
 *
 * @last-modified by: 
 * @last-modified date: 
 * @last-modified time: 
 *
 * @author Swee Zhi
 * @date-created Sep 7, 2011    @time-created 3:11:59 AM
 *
 * @project: 
 * @module: 
 * @institution: 
 *
 */
package entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

@Entity(name="StaffAcct")
public class StaffAccountEntity extends UserAccountEntity implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @OneToOne(cascade={CascadeType.PERSIST})
    private StaffEntity staff;
    
    @OneToMany(cascade = {CascadeType.ALL})
    private List<AccessRightsEntity> accessRights = new ArrayList<AccessRightsEntity>();
    
    public void create(String username, String password, Date creationDate, Date passwordChangeDate) {
        super.setUsername(username);
        super.setPassword(password);
        super.setCreationDate(creationDate);
        super.setPasswordChangeDate(passwordChangeDate);
    }
    
    public void update(String password, Date passwordChangeDate) {
        super.setPassword(password);
        super.setPasswordChangeDate(passwordChangeDate);
    }

//    public void update(String password) {
//        super.setPassword(password);
//    }

    public StaffEntity getStaff() {
        return staff;
    }

    public void setStaff(StaffEntity staff) {
        this.staff = staff;
    }

    public List<AccessRightsEntity> getAccessRights() {
        return accessRights;
    }

    public void setAccessRights(List<AccessRightsEntity> accessRights) {
        this.accessRights = accessRights;
    }
    
}
